﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CarInfor.DAL;

namespace CarInfor.UI
{
    public partial class frmSetAlert : Form
    {
        public frmSetAlert()
        {
            InitializeComponent();
            Bind();
        }

        void Bind()
        {
            AlertSetting setting = new AlertSetting();
            setting.GetSetting();
            this.numYCB.Value = setting.YearCheckAlertB;
            this.numYCE.Value = setting.YearCheckAlertE;
            this.numIJQB.Value = setting.InsurancJQAlertB;
            this.numIJQE.Value = setting.InsurancJQAlertE;
            this.numIBussB.Value = setting.InsurancBussAlertB;
            this.numIBussE.Value = setting.InsurancBussAlertE;
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                AlertSetting setting = new AlertSetting();
                setting.YearCheckAlertB = int.Parse(this.numYCB.Value.ToString());
                setting.YearCheckAlertE = int.Parse(this.numYCE.Value.ToString());

                setting.InsurancJQAlertB = int.Parse(this.numIJQB.Value.ToString());
                setting.InsurancJQAlertE = int.Parse(this.numIJQE.Value.ToString());
                setting.InsurancBussAlertB = int.Parse(this.numIBussB.Value.ToString());
                setting.InsurancBussAlertE = int.Parse(this.numIBussE.Value.ToString());
                setting.Delete();
                setting.Insert();
                MessageHelper.ShowInfo("保存成功！");
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageHelper.ShowFail("保存失败！" + ex.Message);
            }
        }

        private void btnCancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
